package com.lxmes.base.service.impl;

import java.util.List;

import com.lxmes.base.domain.JcProjectMain;
import com.lxmes.base.mapper.JcProjectMainMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lxmes.base.mapper.JcProjectInfoMapper;
import com.lxmes.base.domain.JcProjectInfo;
import com.lxmes.base.service.IJcProjectInfoService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 项目详情Service业务层处理
 * 
 * @author 王超
 * @date 2022-08-27
 */
@Service
public class JcProjectInfoServiceImpl implements IJcProjectInfoService 
{
    @Autowired
    private JcProjectInfoMapper jcProjectInfoMapper;
    @Autowired
    private JcProjectMainMapper jcProjectMainMapper;

    /**
     * 查询项目详情
     * 
     * @param id 项目详情主键
     * @return 项目详情
     */
    @Override
    public JcProjectInfo selectJcProjectInfoById(Long id)
    {
        return jcProjectInfoMapper.selectJcProjectInfoById(id);
    }

    /**
     * 查询项目详情列表
     * 
     * @param jcProjectInfo 项目详情
     * @return 项目详情
     */
    @Override
    public List<JcProjectInfo> selectJcProjectInfoList(JcProjectInfo jcProjectInfo)
    {
        return jcProjectInfoMapper.selectJcProjectInfoList(jcProjectInfo);
    }

    /**
     * 新增项目详情
     * 
     * @param jcProjectInfo 项目详情
     * @return 结果
     */
    @Transactional
    @Override
    public int insertJcProjectInfo(JcProjectInfo jcProjectInfo)
    {
        JcProjectMain jcProjectMain1 = jcProjectMainMapper.selectJcProjectMainById(jcProjectInfo.getMainId());
        jcProjectMain1.setTotalPrice(jcProjectMain1.getTotalPrice().add(jcProjectInfo.getZjPrice()));
        jcProjectMainMapper.updateJcProjectMain(jcProjectMain1);
        return jcProjectInfoMapper.insertJcProjectInfo(jcProjectInfo);
    }

    /**
     * 修改项目详情
     * 
     * @param jcProjectInfo 项目详情
     * @return 结果
     */
    @Override
    public int updateJcProjectInfo(JcProjectInfo jcProjectInfo)
    {
        return jcProjectInfoMapper.updateJcProjectInfo(jcProjectInfo);
    }

    /**
     * 批量删除项目详情
     * 
     * @param ids 需要删除的项目详情主键
     * @return 结果
     */
    @Override
    public int deleteJcProjectInfoByIds(Long[] ids)
    {
        return jcProjectInfoMapper.deleteJcProjectInfoByIds(ids);
    }

    /**
     * 删除项目详情信息
     * 
     * @param id 项目详情主键
     * @return 结果
     */
    @Override
    public int deleteJcProjectInfoById(Long id)
    {
        return jcProjectInfoMapper.deleteJcProjectInfoById(id);
    }
}
